<?php
namespace app\controllers\api\post;

use fate\http\Request;
use app\models\Posts;

class RecommendController extends \fate\web\PureController {

    public function run() {
        $req = Request::getInstance();
        $type = $req->getQueryString('type');

        $order = 'views desc';
        if('cool' === $type) {
            $order = 'views asc';
        }

        $post = new Posts();
        $ret = $post->getListByCondition('id,title', 'status=1', 10, $order);

        $this->ajaxReturn([
            'data' => $ret
        ]);
    }

}
